<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ include file="/commons/taglibs.jsp" %>
<%@ taglib uri="/tag" prefix="tag"%>
<tag:customerLogonCheck/>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>地址列表</title>
<link href="${ctx }/style/common.css" rel="stylesheet" type="text/css" />
<style type="text/css">
	.list_table {margin: 0 auto;margin-top: 10px;}
	.list_table td{ text-align: center;font-family: 宋体;font-size: 12px;}
	#content{background: #ffffff;padding-bottom: 30px;padding-top:20px;border: 1px solid #ccc;width: 960px;margin: 0 auto;margin-top: 5px;}
</style>
<script type="text/javascript">
/******* 默认地址设置  **********/
function setDefault(id,flag){

	location.href = "${ctx}/customer/customerAction!setDefaultAddress.do?id="+id+"&flag="+flag;
}
/*** 修改收货地址 ****/
function modifyAddress(id){
	location.href = "${ctx}/customer/customerAction!modifyAddressPrepare.do?id="+id;
}
/******** 删除收货地址 **************/
function delAddress(id){

	location.href = "${ctx}/customer/customerAction!delAddress.do?id="+id;
}
/******** 新增收货地址 **************/
function addAddress(){

	var size = ${requestScope.sizeOfaddressList};

	if(size >= 5){
		alert("不允许新增收货地址，每个会员最多允许添加五个收货地址。");
		return false;
	}

	location.href = "${ctx}/customer/customerAction!addNewAddressPrepare.do";	
}
</script>
</head>
<body>

	<%@include file="/commons/head.jsp"%>

	<%@include file="/user/customer_menu.jsp"%>
	
	<div id="content">
		<table width="910" border="0" cellpadding="0" cellspacing="1" bordercolor="#cccccc" bgcolor="#cccccc" class="list_table">
                 <tr bgcolor="#fffae6">
                    <td height="35">收货人</td>
                    <td>手机</td>
                    <td>地址</td>
                    <td>邮编</td>
                    <td>邮箱</td>
                    <td>默认地址</td>
                    <td>操作&nbsp;&nbsp;<a style="text-decoration: underline;color: red" href="javascript:addAddress()">新增收货地址</a></td>
                 </tr>
                 <c:forEach items="${requestScope.addressList}" var="result" varStatus="status">
                   <tr bgcolor="#FFFFFF">
	                    <td height="30">${result.consignee }</td>
	                    <td>${result.mobile}</td>
	                    <td>${result.provinceInfo.name }${result.cityInfo.name }${result.address }</td>
	                    <td>${result.zipCode }</td>
	                    <td>${result.email }</td>
	                    <td>
		                    <c:choose>
		                    	<c:when test="${result.defaultFlag =='1'}">是</c:when>
		                    	<c:otherwise>否</c:otherwise>
		                    </c:choose>
	                    </td>
	                    <td>
	                    	<c:choose>
		                    	<c:when test="${result.defaultFlag =='0'}"><a href="javascript:setDefault(${result.id},'1')">设为默认地址</a></c:when>
		                    	<c:otherwise><a href="javascript:setDefault(${result.id},'0')">取消默认</a></c:otherwise>
		                    </c:choose>&nbsp;&nbsp;
		                    <a href="javascript:modifyAddress(${result.id})">修改</a>&nbsp;&nbsp;
		                   	<a href="javascript:delAddress(${result.id})">删除</a>
	                    </td>
                   </tr>
                </c:forEach>
         </table>
	</div>    

	<%@ include file="/commons/foot.jsp" %>
</body>
</html>